One way to isolate errors is to use a message box to display the value of a variable or property at a particular point in the coce. This code example shows the selection length returned from the SelLength property in a message box.
MsgBox Item.GetInspector.ModifiedFormPages("Test").Textbox1.SelLength